using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/**游戏主场景 */
public class GameMain : MonoBehaviour
{
    /**分数文本 */
    public Text scoreText;

    /**胜利界面 */
    public GameObject gameWinPanel;
    
    /**失败界面 */
    public GameObject gameOverPanel;

    /**关卡容器 */
    public GameObject levelPanel;
    
    /**当前关卡 */
    private GameObject _level;
    
    public static GameMain instance;

    private void Awake()
    {
        instance = this;
    }

    /**显示游戏胜利 */
    public void ShowGameWinPanel()
    {
        gameWinPanel.SetActive(true);
    }

    /**显示游戏失败 */
    public void ShowGameOverPanel()
    {
        gameOverPanel.SetActive(true);
    }
    
    /**刷新关卡 */
    public void UpdateLevel(GameObject level)
    {
        gameWinPanel.SetActive(false);
        gameOverPanel.SetActive(false);
        
        Destroy(_level);
        _level = Instantiate(level, levelPanel.transform);
    }
    
    /**刷新分数 */
    public void UpdateTotalScore(int score)
    {
        this.scoreText.text = score.ToString();
    }

}
